package com.kingdee.pda.ui.scan_inwarehouse;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kingdee.pda.R;
import com.kingdee.pda.ui.dialog.OutCheckSnListDialog;

import java.util.ArrayList;
import java.util.List;

/**
 * @author：dlj
 * @data：2021/11/11 15:10
 * @des：
 */
public class ScanReceiveDetailAdapter extends BaseQuickAdapter<ScanReceiveShowDetailBean, BaseViewHolder> {

    private Context context;

    public ScanReceiveDetailAdapter(Context context, List<ScanReceiveShowDetailBean> beans) {
        super(R.layout.item_scanreceive_detail, beans);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder viewHolder, ScanReceiveShowDetailBean item) {
        viewHolder.setText(R.id.tv_spuname, "商品编码：" + item.getSpuname())
                .setText(R.id.tv_spucode, "商品条码：" + item.getSkubarcode().toString())
                .setText(R.id.tv_owner, "货主：" + item.getOwnername())
                .setText(R.id.tv_skuname, "规格名称：" + item.getSkuname())
                .setText(R.id.tv_scanqty, "已扫数量：" + item.getScannedqty() + "")
                .setText(R.id.tv_planqty, "待收数量：" + (item.getPalnqty() - item.getReceiptedqty()) + "");

        if (item.getScannedqty() > 0 && item.getSnlist().size() > 0) {
            TextView ll_snNum = viewHolder.getView(R.id.tv_scanqty);
            ll_snNum.setTextColor(Color.rgb(0, 0, 255));
            ll_snNum.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    OutCheckSnListDialog.showSnListDialog(context, new ArrayList<>(item.getSnlist()));
                }
            });
        }
    }
}
